package com.itany;

public class Test implements Runnable {

    @Override
    public void run() {
        Long requestId=Thread.currentThread().getId();
       try {

          if(RedisDemo2.getRedisLock("lock",requestId+"")){
              for(int i=0;i<10;i++){
                  Thread.sleep(100);
                  System.out.println(Thread.currentThread().getName()+"============="+Thread.currentThread().getId());
              }
          }
       }catch (Exception e){
           e.printStackTrace();
       }finally {
           System.out.println("释放锁的是====="+requestId);
           RedisDemo2.unRedisLock("lock",requestId+"");
       }
    }
}
